package com.devunion.salon.persistence.dao;

import com.devunion.salon.persistence.Login;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Hibernate;

/**
 * @author Viktar Liaskovich
 */
public class LoginDao extends BaseDaoObject<Login>{
    public Login getByKey(Serializable key) {
        return (Login) getHibernateTemplate().get(Login.class, key);
    }

    public Login getByLogin(String login) {
        List results = getSession().createQuery("from Login where login = :login").
                setParameter("login", login, Hibernate.STRING).
                list();

        return (Login) (results.isEmpty() ? null : results.get(0));
    }
}